﻿using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;
using Eneta.Portal.Common;
using Eneta.Portal.Profiles.Controls;

namespace Eneta.Portal.Profiles.WebParts
{
    public class LiteratureWebPart : WebPart
    {
        [WebBrowsable(true)]
        [WebDisplayName("Sündmuse URL")]
        [Category("Kirjanduse sisutüüp")]
        [Personalizable(PersonalizationScope.Shared)]
        public string LiteratureType { get; set; }


        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {
                var control = Page.LoadControl("~/_controltemplates/ProfileLiteratureListControl.ascx") as ProfileLiteratureListControl;
                if (control != null)
                {
                    control.LiteratureType = LiteratureType;
                    Controls.Add(control);
                }
                else
                {
                    Logger.LogInfo("LiteratureWebPart control is null", "LiteratureWebPart_CreateChildControls");
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }

        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            return;
        }

        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            return;
        }
    }
}
